home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / infosrvr / dev / scott / WWW / NextStep / Implementation / TextToy.m < prev    next >
Text File  |  1993-02-01  |  2KB  |  107 lines

  1. //    Text Management Module                    TextToy.m
  2. //    ----------------------
  3.  
  4. //    This file allows one to create links between Hypertexts. It selects the
  5. //    current HyperText and then passes the buck to the HyperText class.
  6.  
  7. #import "TextToy.h"
  8. #import <appkit/appkit.h>
  9. #import "HTAnchor.h"
  10. #import "HyperText.h"
  11. #import <objc/List.h>
  12.  
  13. #import "HTUtils.h"
  14.  
  15. @implementation TextToy
  16.  
  17. #define THIS_TEXT  (HyperText *)[[[NXApp mainWindow] contentView] docView]
  18.  
  19.     HTAnchor *    Mark;        /* A marked Anchor */
  20.     
  21.  
  22. - setSearchWindow:anObject
  23. {
  24.     SearchWindow = anObject;
  25.     return self;
  26. }
  27.  
  28. /*    Action Methods
  29. **    ==============
  30. */
  31.  
  32. /*    Set up the start and end of a link
  33. */
  34. - (HTChildAnchor*) linkToMark:sender
  35. {
  36.     return [THIS_TEXT linkSelTo:Mark];
  37. }
  38.  
  39. - linkToNew:sender
  40. {
  41.     return nil;
  42. }
  43.  
  44. - unlink:sender;
  45. {
  46.     return [THIS_TEXT unlinkSelection];
  47. }
  48.  
  49. - (HTChildAnchor*)markSelected:sender
  50. {
  51.     Mark = (HTAnchor*) [THIS_TEXT referenceSelected];
  52.     return (HTChildAnchor*)Mark;
  53. }
  54. - (HTParentAnchor*) markAll:sender
  55. {
  56.     Mark = (HTAnchor*) [THIS_TEXT referenceAll];
  57.     return (HTParentAnchor*) Mark;
  58. }
  59.  
  60. - (HTChildAnchor*)followLink:sender
  61. {
  62.     return [THIS_TEXT followLink];    // never mind whether there is a link
  63. }
  64.  
  65. - dump : sender
  66. {
  67.     return [THIS_TEXT dump:sender];
  68. }
  69.  
  70. //        Window Delegate Functions
  71. //        -------------------------
  72.  
  73. - windowDidBecomeKey:window
  74. {
  75.     return self;
  76. }
  77.  
  78. //    When a document is selected, turn the index search on or off as
  79. //    appropriate
  80.  
  81. - windowDidBecomeMain:window
  82. {
  83.     HyperText * HT =  [[window  contentView] docView];
  84.     if (!HT) return self;
  85.     
  86.     if ([HT isIndex]) {
  87.     [SearchWindow makeKeyAndOrderFront:self];
  88.     } else {
  89.     [SearchWindow orderOut:self];
  90.     }
  91.     
  92.     return self;
  93. }
  94.  
  95.  
  96. //            Access Management functions
  97. //            ===========================
  98.  
  99. - registerAccess:(HyperAccess *)access
  100. {
  101.     if (!accesses) accesses=[List new];
  102.     return [accesses addObject:access];
  103. }
  104.  
  105.  
  106. @end
  107.